package com.example.huwang.utils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

public class PhoneReceiver extends BroadcastReceiver {
    private static final String TAG = PhoneReceiver.class.getSimpleName();


    @Override
    public void onReceive(Context context, Intent intent) {
        if ("android.intent.action.PHONE_STATE".equals(intent.getAction())) {
            String mCallNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            if (!TextUtils.isEmpty(mCallNumber)) {
                Intent callIntent = new Intent("com.example.huwang.DANGER_CALL");
                callIntent.putExtra("callNum", mCallNumber);
                context.sendBroadcast(callIntent);
             }

        }


    }
}
